package com.sprouting.personal.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sprouting.personal.dao.PsPlanHistoryDao;
import com.sprouting.personal.model.entity.PsPlanHistory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 执行任务历史表
 *
 * @author ：LX（长沙麓谷）
 * @date 创建时间： 2023/1/18 9:31
 */
@Service
@Slf4j
public class PsPlanHistoryService extends ServiceImpl<PsPlanHistoryDao, PsPlanHistory> {

    @Resource
    private PsPlanHistoryDao psPlanHistoryDao;

    /**
     * 分页查询任务执行记录
     * @param page 分页参数
     * @param planId 计划ID
     * @return
     */
    public Page<PsPlanHistory> getTaskHistory(Page<PsPlanHistory> page, String planId) {
        return psPlanHistoryDao.getTaskHistory(page, planId);
    }

    /**
     * 获取最新一条任务执行记录
     * @param planId 计划ID
     * @return
     */
    public PsPlanHistory getLatestRecord(String planId){
        return psPlanHistoryDao.getLatestRecord(planId);
    }
}
